/*
 * @Author: hongbin
 * @Date: 2023-10-12 15:36:12
 * @LastEditors: hongbin
 * @LastEditTime: 2023-10-18 09:58:11
 * @Description:
 */

/**
 * 通用功能
 */
export class Manager {
  constructor(model) {
    this.model = model;
  }
  create(docs, options) {
    return this.model.create(docs, options);
  }
  insert(docs) {
    return this.model.insertMany(docs);
  }
  findAll() {
    return this.model.find({});
  }
  findById(id, projection, options) {
    return this.model.findById(id, projection, options);
  }
  findOne(filter, projection, options) {
    return this.model.findOne(filter, projection, options);
  }
  find(filter, projection, options, callback) {
    return this.model.find(filter, projection, options, callback);
  }
  findByIdAndUpdate(id, update, options, callback) {
    return this.model.findByIdAndUpdate(id, update, options, callback);
  }
  deleteById(id, options) {
    return this.model.deleteOne({ _id: id }, options);
  }
  deleteOne(filter, options) {
    return this.model.deleteOne(filter, options);
  }
  updateMany(filter, update, options) {
    return this.model.updateMany(filter, update, options);
  }
  updateOne(filter, update, options) {
    return this.model.updateOne(filter, update, options);
  }
  deleteMany(filter, options) {
    return this.model.deleteMany(filter, options);
  }
  deleteOne(filter, options) {
    return this.model.deleteOne(filter, options);
  }
  aggregate(pipeline, options) {
    return this.model.aggregate(pipeline, options);
  }
  count(filter) {
    return this.model.count(filter);
  }
}
